package com.mobilepay.moneypig.model.dialog;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.mobilepay.moneypig.R;
import com.mobilepay.moneypig.base.BaseDialog;

/**
 * Created by lm0908 on 2017/8/18.
 */

public class PasswordDialog extends BaseDialog {
    public PasswordDialog(Context context) {
        super(context);
    }

    public PasswordDialog(Context context, int themeResId) {
        super(context, themeResId);
    }

    protected PasswordDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    private EditText mEditPassword;
    private TextView mTextConfirm;
    private TextView mTextCancle;

    @Override
    protected void onSetContentView() {
        setContentView(R.layout.dialog_password);
    }

    @Override
    protected void initViews() {
        mEditPassword = (EditText) findViewById(R.id.password_content);
        mTextConfirm = (TextView) findViewById(R.id.password_comfirm);
        mTextCancle = (TextView) findViewById(R.id.password_cancle);
        initWindow(0.75f, 0);
        setAnimate(R.style.animatedialog);
    }

    @Override
    protected void onSetListener() {
        mTextCancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                cancel();
                listener.onCancle();
            }
        });
        mTextConfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String editPs = mEditPassword.getText().toString();
                listener.onConfirm(editPs);
            }
        });
    }

    private Listener listener;

    public void setListener(Listener listener) {
        this.listener = listener;
    }

    public static class Listener {
        public void onConfirm(String ps) {

        }

        public void onCancle() {

        }

    }


    @Override
    protected void afterOnCreate(Bundle savedInstanceState) {

    }
}
